package cn.itcast.nems.bpm.web.controller.b;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.itcast.nems.approval.service.ApprovalFormFlowInformedReadflagService;
import cn.itcast.nems.common.account.AccountHolder;
import jakarta.websocket.server.PathParam;
import lombok.RequiredArgsConstructor;

/**
 * <p>
 * 流程审批单阅读状态;（限抄送的审批单） 前端控制器
 * </p>
 *
 * @author CodeGenerator
 * @since 2024-01-05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/b/bpm/approval/form/{formId}/informed/readflag")
public class ApprovalFormFlowInformedReadflagController {

    private final ApprovalFormFlowInformedReadflagService approvalFormFlowInformedReadflagService;
    
    /**
     * 
     * 功能描述：标记抄送的审批单为已读
     *
     * @param formId 审批单ID
     * @return 成功消息文本
     * 
     * @author 刘曙
     *
     * @since 2024年1月5日
     *
     * @update:[变更日期YYYY-MM-DD][更改人姓名][变更描述]
     */
    @PostMapping
    public ResponseEntity<String> create(@PathVariable("formId") String formId) {
        approvalFormFlowInformedReadflagService.save(formId, AccountHolder.getRequiredAccountInfo().getEmail());
        return new ResponseEntity<>("审批单已为当前用户标记为已读！", HttpStatus.CREATED);
    }
}
